package com.example.mapper;

import com.example.entity.Clazz;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ClazzMapper {

    List<Clazz> selectAll(Clazz clazz);

    @Insert("insert into clazz (class_name,major_id,teacher_id) values (#{className},#{majorId},#{teacherId})")
    void insert(Clazz clazz);

    @Update("update clazz set class_name = #{className},major_id = #{majorId},teacher_id = #{teacherId} WHERE class_id = #{classId}")
    void update(Clazz clazz);

    @Delete("DELETE FROM clazz WHERE class_id = #{classId}")
    void delete(Integer classId);

    @Select("select count(*) from clazz where major_id=#{majorId}")
    int countByMajorId(Integer majorId);

    @Select("select count(*) from clazz where class_name=#{className}")
    int countByClassName(String className);

    @Select("select * from clazz where class_id=#{classId}")
    Clazz selectById(Integer classId);

    @Select("select count(*) from clazz where teacher_id=#{teacherId}")
    int countByTeacherId(Integer teacherId);
}
